package DynamicProgramming;

public class _746_MinCostClimbingStairs {
    public int minCostClimbingStairs(int[] cost) {
        int[] minCost = new int[cost.length];
        minCost[0] = cost[0];
        minCost[1] = cost[1];
        for (int i = 2; i <cost.length ; i++) {
            minCost[i] = (minCost[i - 1] > minCost[i - 2] ? minCost[i - 2] : minCost[i - 1]) + cost[i];
        }
        return (minCost[cost.length - 1]>minCost[cost.length-2]?minCost[cost.length-2]:minCost[cost.length-1]);
    }
}
